// @ts-nocheck
const vscode = require('vscode')
const {provideDefinitionFn} = require('../dist/bundle')
// const {provideDefinitionFn} = require('./fileFrom')

function provideDefinition(document, position, token) {
  return provideDefinitionFn(document, position, token).then(({path, pos, isFile}) => {
    if(!isFile && pos.x === 0 && pos.y === 0) {
      return undefined
    }
    return new vscode.Location(vscode.Uri.file(path), new vscode.Position(pos.y, pos.x));
  })
}

module.exports = context => {
  context.subscriptions.push(vscode.languages.registerDefinitionProvider(['javascript', 'vue'], {
    provideDefinition
  }))
}

